<!DOCTYPE HTML>
<html lang="zh-CN">

<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type"content="text/html; charset=utf-8"/>
<meta name="viewport"content="width=device-width, initial-scale=1">
<title>裹站下载</title>
<style>
  .download {
    width: 300px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -150px;
    margin-top: -115.5px;
  }
  .ios {
    width: 400px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -200px;
    margin-top: -140px;
  }
  .ios{
    width: 100%;
    left: 0;
    margin-left: 0;
    text-align: center;
  }
  .ios>img{
    max-width: 400px;
  }
  .back {
    margin: 20px auto;
    width: 180px;
    text-align: center;
    background: #3FC2FF;
    color: #fff;
    font-size: 20px;
    display: block;
    font-family: "微软雅黑";
    padding: 7px 10px;
    border-radius: 4px;
    text-decoration: none;
  }
</style>
</head>

<body>
<img id="weixin"style="display:none;"width="100%"src="images/weixin.jpg">
<div class="download"id="pc"style="display:none;">
<img width="100%"src="images/download.gif">
</div>
<div class="ios"id="ios"style="display:none;">
  <img width="100%"src="images/ios.jpg">
  <a class="back" href="#" onClick="javascript :history.back(-1);">返回</a>
</div>
<script type="text/javascript">
function doLocation(url) {
  var a = document.createElement("a");
  if (!a.click) {
    window.location = url;
    return;
  }
  a.setAttribute("href", url);
  a.style.display ="none";
  document.body.appendChild(a);
  a.click();
}
function GetQueryString(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) return unescape(r[2]);
  return null;
}
// 获取终端的相关信息
var Terminal = {
  // 辨别移动终端类型
  platform:function() {
    var u = navigator.userAgent, app = navigator.appVersion;

    return {
      weixin: u.indexOf('MicroMessenger') > -1, // android终端或者uc浏览器
      android:u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, // 是否为iPhone或者QQHD浏览器
      iPhone:u.indexOf('iPhone') > -1, // 是否iPad
      iPad:u.indexOf('iPad') > -1
    }
    ;
  }
  (), // 辨别移动终端的语言：zh-cn、en-us、ko-kr、ja-jp...
  language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
window.onload = function() {
  // 根据不同的终端，跳转到不同的地址
  var action = GetQueryString('action');
  //用户类别
  var phoneType = GetQueryString('phone')
  var androidAppUrl ='';
  //默认安卓地址
  var iphoneAppUrl ='';

  //默认苹果地址
  if (action == 'user') {
    androidAppUrl ='http://download.5ohome.com/android/5ohome_user.apk';
    //用户安卓地址
    iphoneAppUrl ='itms-services://?action=download-manifest&url=https://code.csdn.net/enterprisehome/ehome/blob/master/5ohome_user.plist'//用户苹果地址
  } else if (action == 'courier') {
    androidAppUrl ='http://download.5ohome.com/android/5ohome_courier.apk';
    //快递员安卓地址
    iphoneAppUrl ='itms-services://?action=download-manifest&url=https://code.csdn.net/enterprisehome/ehome/blob/master/5ohome_courier.plist'//快递员苹果地址
  } else if (action == 'mail') {
    androidAppUrl ='http://download.5ohome.com/android/5ohome_postman.apk';
    //邮递员安卓地址
    iphoneAppUrl ='itms-services://?action=download-manifest&url=https://code.csdn.net/enterprisehome/ehome/blob/master/5ohome_postman.plist'//邮递员苹果地址
  }

  if (Terminal.platform.weixin) {
    theUrl ='weixin';
  }
  else if (Terminal.platform.android) {
    theUrl = androidAppUrl;
  }
  else if (Terminal.platform.iPhone || Terminal.platform.iPad) {
    theUrl = iphoneAppUrl;
  }
  else {
    theUrl ='pc';
    //这个是pc的
  }

  if (theUrl == 'pc') {
    if (phoneType == 'android') {
      document.getElementById("pc").style.display ="";
      doLocation(androidAppUrl);
    }
    else if(phoneType == 'ios') {
      document.getElementById("ios").style.display ="";
      doLocation(iphoneAppUrl);
    }
  }else if (theUrl == 'weixin') {
    document.getElementById("weixin").style.display ="";
  }
  else{
    if (Terminal.platform.android) {
      document.getElementById("pc").style.display ="";
      doLocation(androidAppUrl);
    }
    else if(Terminal.platform.iPhone || Terminal.platform.iPad) {
      document.getElementById("pc").style.display ="";
      doLocation(iphoneAppUrl);
    }
    else{
      document.getElementById("pc").style.display ="";
      console.log('url'+ theUrl);
      doLocation(theUrl);
    }
  }
}
</script>
</body>

</html>